<script lang="ts" setup>
// do not use same name with ref
const form = ref({
  name: '',
  region: '',
  dates: {
    date1: '',
    date2: '',
  },
  delivery: false,
  type: [],
  resource: '',
  desc: '',
})

function onSubmit() {
  console.log('submit!')
}
</script>

<template>
  <el-form :model="form" label-width="auto" max-w-600px>
    <el-form-item label="输入框">
      <el-input v-model="form.name" />
    </el-form-item>

    <el-form-item label="选择框">
      <el-select v-model="form.region" placeholder="please select your zone">
        <el-option label="Zone one" value="shanghai" />
        <el-option label="Zone two" value="beijing" />
      </el-select>
    </el-form-item>

    <el-form-item label="时间选择">
      <el-form-item important:flex-nowrap w="45%">
        <el-col>
          <el-date-picker v-model="form.dates.date1" type="date" placeholder="Pick a date" style="width: 100%" />
        </el-col>
      </el-form-item>

      <el-col :span="2" class="text-center">
        <span class="text-gray-500">-</span>
      </el-col>

      <el-form-item important:flex-nowrap w="45%">
        <el-col>
          <el-time-picker v-model="form.dates.date2" placeholder="Pick a time" style="width: 100%" />
        </el-col>
      </el-form-item>
    </el-form-item>

    <el-form-item label="开关">
      <el-switch v-model="form.delivery" />
    </el-form-item>

    <el-form-item label="多选">
      <el-checkbox-group v-model="form.type" flex flex-wrap>
        <el-checkbox value="Online activities" name="type">
          Online activities
        </el-checkbox>
        <el-checkbox value="Promotion activities" name="type">
          Promotion activities
        </el-checkbox>
        <el-checkbox value="Offline activities" name="type">
          Offline activities
        </el-checkbox>
        <el-checkbox value="Simple brand exposure" name="type">
          Simple brand exposure
        </el-checkbox>
      </el-checkbox-group>
    </el-form-item>

    <el-form-item label="单选">
      <el-radio-group v-model="form.resource">
        <el-radio value="Sponsor">
          Sponsor
        </el-radio>
        <el-radio value="Venue">
          Venue
        </el-radio>
      </el-radio-group>
    </el-form-item>

    <el-form-item label="文本框">
      <el-input v-model="form.desc" type="textarea" />
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="onSubmit">
        Create
      </el-button>
      <el-button>Cancel</el-button>
    </el-form-item>
  </el-form>
</template>
